<%--
  Created by IntelliJ IDEA.
  User: 乐乐
  Date: 2021/7/13
  Time: 10:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%String path = request.getContextPath();%>
<head>
    <title>Title</title>
    <link rel="shortcut icon" href="img/bitbug_favicon2.ico" />
    <script type="text/javascript" src="<%=path%>/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript">
        function toRegister(){
            alert(111)
            $.ajax({
                url : "<%=path%>/go/insertByUser",
                type :"get",
                data:$("#formRegister").serialize(),
                dataType : "json",
                async :true,
                success : function(result) {
                    if(result){
                        alert("注册成功")
                    }
                },
                error : function (result) {
                    alert("网络异常")
                }
            })
        }
    function toLogin() {
        $.ajax({
            url : "<%=path%>/go/selectByName",
            type :"get",
            data:$("#formLogin").serialize(),
            dataType : "json",
            async :true,
            success : function(result) {
                if(result){
                    location.href="<%=path%>/to/getInfo";
                    alert("注册成功")
                }
            },
            error : function (result) {
                alert("网络异常")
            }
        })
    }
    </script>
</head>
<body>
    <form id ="formRegister">
        用户名:<input type="text" name ="uname"><br>
        密码:<input type="text"name="password">
        <input type="button" onclick="toRegister()" value="注册">
    </form>
</body>
</html>
